import { getSysStructDetailApi, getSysStructsTreeApi } from './department-detail.service';
export default {
  name: 'department-detail',
  components: {},
  directives: {},
  props: {
    structId: {
      type: Object,
      default: () => null
    }
  },
  data() {
    return {
      loading: false, // table loading
      showDialog: true, // 是否显示弹窗
      structs: [], // 上级部门列表
      title: '部门详情',
      editForm: {} // 编辑用户表单
    }
  },
  created() {
    this.getSysStruct();
    this.getSysStructDetail();
  },
  methods: {
    // 获取组织树
    getSysStruct() {
      getSysStructsTreeApi().then(res => {
        this.structs = res.data[0].children
      });
    },

    // 获取部门详情
    getSysStructDetail() {
      getSysStructDetailApi(this.structId).then(res => {
        this.editForm = res.data
      })
    },

    // 关闭dialog时需要告诉父组件隐藏弹窗
    closeDialog() {
      this.showDialog = false;
      this.$emit('close', true);
    }
  }
}
